package com.rututor.server.dao;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.ObjectifyService;
import com.googlecode.objectify.util.DAOBase;
import com.rututor.server.entities.Course;
import com.rututor.server.entities.RequestTutor;
import com.rututor.server.entities.Tutor;
import com.rututor.server.entities.UserInfo;

public class RequestTutorDAO extends DAOBase {
	private UserInfoDAO uiDAO = new UserInfoDAO();
	private TutorDAO tutorDAO = new TutorDAO();
	private CourseDAO courseDAO = new CourseDAO();

	static {
		ObjectifyService.register(RequestTutor.class);
	}

	public void addTutorRequest(Long courseId, Long tutorId, String email) {

		RequestTutor rt = new RequestTutor(
				courseDAO.getKeyByCoursrId(courseId),
				tutorDAO.getKeyByTutorId(tutorId), uiDAO.getKeyFromId(email));
		ofy().put(rt);
		assert rt.getRequestId() != null; // id was autogenerated

	}

}
